<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Title</title>
  </head>
  <body>
    <span>请输入密码：</span>
    <input type="password" title="password" />
    <span class="info">要求密码为6-12位</span>
    <script>
      var info = document.querySelector(".info");
      var pas = document.querySelector("input");
      pas.onblur = function () {
        if (pas.value.length < 6 || this.value.length > 12)
          info.innerHTML = "密码长度不符合要求";
      };
    </script>
  </body>
</html>
